package http;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/session")
public class SessionServlet extends HttpServlet {
    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        Object data = request.getParameter("data");
        HttpSession session =  request.getSssion();
        if(data != null){
            session.setAttribute("data",data);
        }

        PrintWriter out = response.getWriter();
        out.append("<HTML><body><h1>");
        out.println(session.getAttribute("data"));
        out.append("</h1></body></HTML>");
    }
}
